package ch.selise.exercise.pattern.notepad.ui;

import java.util.Scanner;

import ch.selise.exercise.pattern.notepad.command.CommandCreationFactory;
import ch.selise.exercise.pattern.notepad.command.CommandExecutor;
import ch.selise.exercise.pattern.notepad.command.GetCommandParameter;
import ch.selise.exercise.pattern.notepad.command.ICommand;
import ch.selise.exercise.pattern.notepad.exception.EmptyStackException;
import ch.selise.exercise.pattern.notepad.exception.ExecuteException;
import ch.selise.exercise.pattern.notepad.exception.UnsupportedCommandException;

public class MainUI {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		CommandExecutor ce = CommandExecutor.getInstance();

		String commandText = "";

		while (true) {

			commandText = in.nextLine();

			//ICommand command;
			try {
				//command = CommandCreationFactory.getCommand(new GetCommandParameter(commandText, in, ce));
				//command.execute();
				ce.executeCommand(new GetCommandParameter(commandText, in));
			} catch (UnsupportedCommandException e1) {
				e1.printStackTrace();
			} catch (ExecuteException e) {
				e.printStackTrace();
			} catch (EmptyStackException e) {
				e.printStackTrace();
			}

		}

		// in.close();
		// System.out.println(TextStorageSingleton.getInstance().getText());

	}

}
